package MetaClassifierAlgorithms;

import Definitions.GraphClass;
import Global.GlobalClass;
import Sampling.SamplingAbstractClass;
import Utility.WorkerUtilityClass;

public class MaxMetaClassifierClass extends MetaClassifierAbstractClass{
	MaxMetaClassifierClass(String metaClassifierName, GraphClass graph,
			GlobalClass global, SamplingAbstractClass currentSampling, double[][][] probabilityDistributionMatrixForTheClassifiers) {
		
		super(metaClassifierName, graph, global, currentSampling, probabilityDistributionMatrixForTheClassifiers);
		// TODO Auto-generated constructor stub
	}

	public void metaClassify()
	{
		double[] mergedFormOfTheProbabilitiesPerClassBasis ;		
		int metaClassLabelEstimated;
		
		for(int nodeNo=0; nodeNo<probabilityDistributionMatrixForTheClassifiers[0].length; nodeNo++)
		{
			mergedFormOfTheProbabilitiesPerClassBasis = probabilityDistributionMatrixForTheClassifiers[0][nodeNo];			
			
			for(int j=1; j<probabilityDistributionMatrixForTheClassifiers.length; j++)
			{
				mergedFormOfTheProbabilitiesPerClassBasis = WorkerUtilityClass.mergeTwoDoubleArrays(mergedFormOfTheProbabilitiesPerClassBasis, probabilityDistributionMatrixForTheClassifiers[j][nodeNo]);
			}
			
			metaClassLabelEstimated = WorkerUtilityClass.findMaxIndexForTheGivenVector(mergedFormOfTheProbabilitiesPerClassBasis);
			metaClassLabelEstimated = metaClassLabelEstimated % global.classSize; 
		
			currentSampling.setClassLabelEstimated(currentSampling.getTestNodes().get(nodeNo), metaClassLabelEstimated);			
		}		
	}
}
